libxl/gentypes.py: special-case KeyedUnion map handle generation
authorWei Liu <wei.liu2@citrix.com>
Mon, 9 Jun 2014 12:43:21 +0000 (13:43 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 10 Jun 2014 13:08:27 +0000 (14:08 +0100)
commit0ae765d434adbef6effe9c5dde8b241e4c299269
tree9edff7a6cda4149cac795b1142e72ac6d3673f67
parent752f181fefb740523522b5730efdef28b0ff91ff
libxl/gentypes.py: special-case KeyedUnion map handle generation

Generate JSON map handle according to KeyedUnion discriminator.

The original JSON output for a keyed union is like:
 {
   ...
   "u" : { FIELDS }
   ...
 }

The discriminator is not generated, so that the parser won't be able to
figure out the fields in the incoming stream.

So we need to change this to something more sensible. For example, for
keyed union libxl_domain_type, which has a discriminator called "type",
we generate following for HVM guest:
 {
   ...
   "type.hvm" : { HVM FIELDS }
   ...
 }

Parser then can know the type of this union and how to interpret the
incoming stream.

Note that we change the existing API here. However the original output is
quite broken anyway, we cannot make sensible use of it and I doubt that
there's existing user of existing API. So we are acutally fixing a
problem.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/gentypes.py